package com.javatest.springboottest01.config;

import org.springframework.boot.task.TaskExecutorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
public class AsyncConfig {

    @Bean("ThreadPool01")
    ThreadPoolTaskExecutor threadPoolTeskExecutor1(TaskExecutorBuilder builder) {
        return builder
                .corePoolSize(6)
                .threadNamePrefix("pool01-")
                .build();
    }

    @Bean("ThreadPool02")
    ThreadPoolTaskExecutor threadPoolTeskExecutor2(TaskExecutorBuilder builder) {
        return builder
                .corePoolSize(10)
                .threadNamePrefix("pool02-")
                .build();
    }
}
